<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>培训课程</title>
<script type="text/javascript" src="../static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="../static/easyui/jedate.min.js"></script>
<script type="text/javascript" src="../static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/easyui/themes/metro-orange/easyui.css">
<link rel="stylesheet" href="../static/easyui/themes/metro-red/window.css">
<link rel="stylesheet" href="../static/ttt/css/TrainingCourse.css?<%=Math.random()%>">
<script type="text/javascript" src="../static/ttt/js/TrainingCourse.js?<%=Math.random()%>"></script>


</head>
<body>
<script type="text/javascript">
function course_table(){
	$('#TrainingCourse').datagrid({    
		 url:'TrainingCourse', //数据源地址
	    columns:[[    
	    	{field:'RUSID',fixed:false,width:213,title:'课程编号',align:'center'},    
	        {field:'RUSNAME',fixed:false,width:213,title:'课程名称',align:'center'},    
	        {field:'EMPNAME',fixed:false,width:213,title:'培训老师',align:'center'},
	        {field:'JNXXNAME',fixed:false,width:213,title:'培训技能',align:'center'},
	        {field:'RUSTIME',fixed:false,width:213,title:'课程时长',align:'center'},
	        {field:'RUSDATE',fixed:false,width:213,title:'创建日期',align:'center',
	        	formatter : function(value){
	        		var d = new Date(value);
	        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
	        		return times;
	        	}
	        } ,
	      /*   {field:'caozuo',fixed:false,width:213,formatter:operate_formatter,title:'操作'}  */
	        
			    
	    ]],
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]  
	}); 
}
$(function(){
	course_table();
	//在每个操作列里面添加编辑，查看，明细，删除
/* 	function operate_formatter(value, row, index) {
       return "<span href='#' class='easyui-linkbutton'>编辑</span>/\
       <span href='#' class='easyui-linkbutton'>删除</span> ";
   } */
	//点击新增按钮弹框
	$("#addTrainingCourse").click(function(){
		$("#addTrainingCourse_win").window("open");
	})
	//关闭窗口
	$("#TrainingCourse_quxiao").click(function(){
		$("#addTrainingCourse_win").window("close");
	})
	//点击确定新增课程
	$("#TrainingCourse_queding").click(function(){
		//课程时长
		var rustime=$("#addTrainingCourse_win_calsstimetext").val();
		//课程名称
		var rusname=$("#addTrainingCourse_win_classnametext").val();
		
		var val1 = parseInt(rustime);
		if(rustime!=""&&rusname!=""){
			if(!isNaN(val1)&&val1>=0){
				if(rustime.indexOf(".")==-1){
					
					//培训讲师
					var empid=$("#cur_emp option:selected").attr("id");
					//培训技能
					var jnxxid=$("#cur_jnxx option:selected").attr("id");
					//描叙
					var rusmiaos=$("#addTrainingCourse_win_calsstemiaoshutext").val();
					$.ajax({
						type:"post",
						url:'add_rus', //数据源地址。
						data:{
							rusname:rusname,
							rustime:rustime,
							rusmiaos:rusmiaos,
							empid:empid,
							jnxxid:jnxxid
						},
						success: function(data){  
							course_table();
						}
						
					});
					$("#addTrainingCourse_win").window("close");
				}else{
					$.messager.show({
						title:'信息提示',
						msg: '请输入正整数',
						timeout:1500,  //1秒后消失
						showType:'slide',//弹出的方式。类似ppt里的图片弹出方式
						//弹出框的样式。居中显示
						style:{
							
						}
					});
				}
			}else if(isNaN(val1)){
				$.messager.show({
					title:'信息提示',
					msg: '请输入数字',
					timeout:1500,  //1秒后消失
					showType:'slide',//弹出的方式。类似ppt里的图片弹出方式
					//弹出框的样式。居中显示
					style:{
						
					}
				});
			}else if(val1<=0){
				$.messager.show({
					title:'信息提示',
					msg: '课程时长不能为负数',
					timeout:1500,  //1秒后消失
					showType:'slide',//弹出的方式。类似ppt里的图片弹出方式
					//弹出框的样式。居中显示
					style:{
						
					}
				});
			}
		}else{
			$.messager.show({
				title:'信息提示',
				msg: '请输入课程名称或课程时长',
				timeout:1500,  //1秒后消失
				showType:'slide',//弹出的方式。类似ppt里的图片弹出方式
				//弹出框的样式。居中显示
				style:{
					
				}
			});
		}
	})
	//根据课程名称查询
	$("#selectTrainingCourse").click(function(){
		var text=$("#texts").val();
		
		if(text!=""){
			$('#TrainingCourse').datagrid({    
				 url:'TrainingCourse_name', //数据源地址
				 queryParams: {  		
					 text:text		
				 },
			    columns:[[    
			    	{field:'RUSID',fixed:false,width:213,title:'课程编号',align:'center'},    
			        {field:'RUSNAME',fixed:false,width:213,title:'课程名称',align:'center'},    
			        {field:'EMPNAME',fixed:false,width:213,title:'培训老师',align:'center'},
			        {field:'JNXXNAME',fixed:false,width:213,title:'培训技能',align:'center'},
			        {field:'RUSTIME',fixed:false,width:213,title:'课程时长',align:'center'},
			        {field:'RUSDATE',fixed:false,width:213,title:'创建日期',align:'center',
			        	formatter : function(value){
			        		var d = new Date(value);
			        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
			        		return times;
			        	}
			        } ,
			      /*   {field:'caozuo',fixed:false,width:213,formatter:operate_formatter,title:'操作'}  */
			        
					    
			    ]]
			});
		}else if(text==""){
			course_table();
		}
		
	})
})
</script>
<div id="addTrainingCourse_win" class="easyui-window" title="培训课程新增" style="width:720px;height:350px"
		    		data-options="modal:true,resizable: false,draggable:false,closed:true,minimizable:false,maximizable:false,collapsible:false">
		    	
		    		<div id="addTrainingCourse_win_box" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_calssname" class="addPayment_win_TrainingCourse" style="">课程名称：</a>
						<input id="addTrainingCourse_win_classnametext" class="addTrainingCourse_win_text" type="text"/>
					</div>
<!-- 					<div id="addTrainingCourse_win_box1" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_calssteacher" class="addPayment_win_TrainingCourse" style="">课程名称：</a>
						<input id="addTrainingCourse_win_calssteachertext" class="addTrainingCourse_win_text" type="text"/>
					</div> -->
					<div id="addTrainingCourse_win_box2" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_calsstime" class="addPayment_win_TrainingCourse" style="">课程时长：</a>
						<input id="addTrainingCourse_win_calsstimetext" class="addTrainingCourse_win_text" type="text"/>
					</div>
					<div id="addTrainingCourse_win_box4" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_teacher" class="addPayment_win_TrainingCourse" style="">培训讲师：</a>
<!-- 						<input id="addTrainingCourse_win_teachertext" class="addTrainingCourse_win_text" type="text"/>
 -->					
 						<select id="cur_emp" style="height: 25px;width:174px;">
 							<c:forEach items="${rus_emp}" var="r">
 								<option id="${r.EMPID}">${r.EMPNAME }</option>
 							</c:forEach>
 						</select>
 					</div>
					<div id="addTrainingCourse_win_box5" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_jineng" class="addPayment_win_TrainingCourse" style="">培训技能：</a>
<!-- 						<input id="addTrainingCourse_win_jinengtext" class="addTrainingCourse_win_text" type="text"/>
 -->					<select id="cur_jnxx" style="height: 25px;width:174px;">
 							<c:forEach items="${rus_jnxx}" var="jnxx">
 								<option id="${jnxx.JNXXID}">${jnxx.JNXXNAME}</option>
 							</c:forEach>
 						</select>
					</div>
					<div id="addTrainingCourse_win_box3" class="addTrainingCourse_win_box">
						<a id="addTrainingCourse_win_calsstemiaoshu" class="addPayment_win_TrainingCourse" style="">课程描叙：</a>
						<textarea cols="50" rows="10"  id="addTrainingCourse_win_calsstemiaoshutext" class="addTrainingCourse_win_text" type="text"></textarea>
					</div>
					
					<hr id="TrainingCourseHr">
					<div class="TrainingCourse_win_box7">
						<button id="TrainingCourse_queding" style="margin-right:15px;">确定</button>
						<button id="TrainingCourse_quxiao">取消</button>
					</div>
					
		    	</div>
		    	<div class="head_1">
					<span class="fontstyle">课程名称：<span>
					<input id="texts" class="TrainingCourse">
					<button id="selectTrainingCourse" style="margin-right:15px;">查询</button>
					<button id="addTrainingCourse">新增</button>
				</span>
				<div id="TrainingCoursetable_1">
					<table id="TrainingCourse" class="easyui-datagrid" style="width:calc(100% - 10px);height:470px;" data-options="fitColumns:true">
					
					</table>
				</div>
</body>
</html>